#include<bits/stdc++.h>
using namespace std;
int T,n,m,L,V;//n is the number of car, m is the number of detectors,L is the length of main road, V is the limitation speed
int d[10010],v[10010],a[10010],p[10010];
int chao[10010];
vector<int> s[10010];
int qu[10010];
int dpx[10010][2];
int truth[10010][2];
bool chaosu(int dd,int vv,int aa){
    if( (V*V) >= (vv*vv + 2*aa*dd) ) return false;
    return true;
}
bool chaoju(int dd,int vv,int aa){
    if( ( (L-dd)*2*aa ) <= vv) return true;
    return false;
}
bool if_empty(int q[],vector<int> ss[],int cha[]){
    for(int i=1;i<=m&&q[i]==1;i++){
        cout<<i<<endl;
        while(!ss[i].empty()) cha[ss[i].back()]--,ss[i].pop_back();
    }
    for(int i=1;i<=n;i++) if(cha[i]>0) return false;
    return true;
}
int dp(int mm,int th,int qs[]){
    if(mm==0) return 0;
    if(th==1){
        qs[mm]=0;
        if(if_empty(qs,s,chao)) return 1+max(dp(mm-1,1,qs),dp(mm-1,0,qs));
    }
    return max(dp(mm-1,1,qs),dp(mm-1,0,qs));
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);

    cin>>T;

    for(int t=1;t<=T;t++){
        int ans=0,num=0;
        memset(d,0,sizeof(d));
        memset(v,0,sizeof(v));
        memset(a,0,sizeof(a));
        memset(p,0,sizeof(p));
        memset(s,0,sizeof(s));
        memset(dpx,0,sizeof(dpx));
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(int i=1;i<=n;i++) scanf("%d%d%d",&d[i],&v[i],&a[i]);
        for(int i=1;i<=m;i++) scanf("%d",&p[i]);
        for(int i=1;i<=n;i++){
            int fact=0;
            if(a[i]>=0){
                for(int j=1;j<=m;j++){
                    if(p[j]>=d[i]){
                        if(chaosu(p[j]-d[i],v[i],a[i])) s[j].push_back(i),fact=1;
                    }
                }
            }
            else{
                if(chaoju( L-d[i] ,v[i],a[i]) ) {
                    for(int j=1;j<=m;j++){
                        if(p[j]>=d[i]){
                            if(chaosu(p[j]-d[i],v[i],a[i])) s[j].push_back(i),fact=1;
                        }
                    }  //jian_su_shi_dui_neng_zou_chu_zhu_gan_dao_de_pan_duan
                }
                else{
                    int d_left=L-d[i]-v[i]*v[i]/(2*a[i]);

                    for(int j=1;j<=m;j++){
                        if(p[j]>=d[i]&&p[j]<=d_left){
                            if(chaosu(p[j]-d[i],v[i],a[i])) s[j].push_back(i),fact=1;
                        }
                    }
                }

            }
            if(fact) ans++,chao[i]++;
        }
        for(int i=1;i<=m;i++) qu[i]=1;
        num=dp(m+1,0,qu);
        cout<<ans<<" "<<(num+ans);

        cout<<endl;
    }
    return 0;
}
